import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
   A simple data source for getting database connections. 
   
   Adapted from the class presented in Big Java
*/
public class Connect
{
   /**
      Initializes the data source.
   */
   public static void init()
         throws ClassNotFoundException
   {  
      String driver = "com.mysql.jdbc.Driver";
      
      // replace userid with your MySQL login name
      url = "jdbc:mysql://localhost/dcspg6";
      username = "dcspg6";
      
      // replace xyz123 with your MySQL password
      password = "sn00py!!";
      Class.forName(driver);
   }

   /**
      Gets a connection to the database.
      @return the database connection
   */
   public static Connection getConnection() throws SQLException
   {
      return DriverManager.getConnection(url, username, password);
   }

   private static String url;
   private static String username;
   private static String password;
}
